<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"> 

<h:head></h:head> 
<f:metadata>
	<f:viewParam name="pid" value="#{modifyProductBean.productId}" />
	<f:viewParam name="tid" value="#{modifyProductBean.productTypeId}" />
	<f:viewAction action="#{modifyProductBean.init}" />
</f:metadata>
<body> 
<p:panelGrid columns="3" cellpadding="0">
		<h:form id="meanForm" rendered="#{modifyProductBean.isMean}">
			<p:panelGrid cellpadding="5" columns="3" id="meanPanel"
				style="height: 100%">
				<f:facet name="header">
					<p:outputLabel value="Add transport mean" />
				</f:facet>

				<p:outputLabel value="name: " for="nameMChoice" />
				<p:inputText id="nameMChoice" value="#{modifyProductBean.mean.name}"
					size="25" />
				<p:message for="nameMChoice" />

				<p:outputLabel value="type: " for="typeChoice" />
				<p:outputLabel id="typeChoice" value="#{modifyProductBean.mean.meanType}" />
				<p:message for="typeChoice" />

				<p:outputLabel value="destination: " for="destinationChoice" />
				<p:outputLabel id="destinationChoice" value="#{modifyProductBean.mean.location.name}" />
				<p:message for="destinationChoice" autoUpdate="true" />

				<p:outputLabel value="departure: " for="departureChoice" />
				<p:selectOneMenu id="departureChoice"
					value="#{modifyProductBean.mean.departure}"
					converter="departureConverter">
					<f:selectItem itemLabel="Select One" itemValue="" />
					<f:selectItems value="#{applicationDataBean.departures}" var="d"
						itemLabel="#{d.name}" itemValue="#{d}" />
				</p:selectOneMenu>
				<p:message for="departureChoice" />

				<p:outputLabel value="space: " for="spaceSelection" />
				<p:spinner id="spaceSelection"
					value="#{modifyProductBean.mean.spaces}" min="0" max="100" />
				<p:message for="spaceSelection" />

				<p:outputLabel value="price: " for="priceMSelection" />
				<p:inputText id="priceMSelection"
					value="#{modifyProductBean.mean.price}">
					<f:validator validatorId="numberValidator" />
				</p:inputText>
				<p:message for="priceMSelection" autoUpdate="true" />

				<f:facet name="footer">
					<p:commandButton value="Update" action="#{modifyProductBean.saveMean()}"
						update=":meanForm" />
					<p:commandButton value="Delete" action="#{modifyProductBean.deleteMean()}"
						update=":meanForm" />	
				</f:facet>
			</p:panelGrid>
		</h:form>

		<h:form id="hotelForm" rendered="#{modifyProductBean.isHotel}">
			<p:contextMenu for="rooms" widgetVar="cMenu">
				<p:menuitem value="Edit Cell" icon="ui-icon-search"
					onclick="PF('roomsTable').showCellEditor();return false;" />
				<p:menuitem value="Hide Menu" icon="ui-icon-close"
					onclick="PF('cMenu').hide()" />
			</p:contextMenu>
			<p:panelGrid id="hotelPanel" style="height: 100%">
				<f:facet name="header">
					<p:row>
						<p:column colspan="3">
							<p:outputLabel value="Add hotel" />
						</p:column>
					</p:row>
				</f:facet>
				<p:row>
					<p:column>
						<p:outputLabel value="name: " for="nameHChoice" />
					</p:column>
					<p:column>
						<p:inputText id="nameHChoice"
							value="#{modifyProductBean.hotel.name}" size="25" />
					</p:column>
					<p:column>
						<p:message for="nameHChoice" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<p:outputLabel value="location: " for="locationHChoice" />
					</p:column>
					<p:column>
						<p:selectOneMenu id="locationHChoice"
							value="#{modifyProductBean.hotel.location}"
							converter="locationConverter">
							<f:selectItem itemLabel="Select One" itemValue="" />
							<f:selectItems value="#{applicationDataBean.locations}" var="l"
								itemLabel="#{l.name}" itemValue="#{l}" />
						</p:selectOneMenu>
					</p:column>
					<p:column>
						<p:message for="locationHChoice" />
					</p:column>
				</p:row>
				<p:row>
					<p:column colspan="2">
						<p:dataTable id="rooms" var="r" value="#{modifyProductBean.rooms}"
							editable="true" editMode="cell" widgetVar="roomsTable">

							<p:column headerText="Room type">
								<p:outputLabel value="#{r.type.toString()}" />
							</p:column>

							<p:column headerText="Number">
								<p:cellEditor>
									<f:facet name="output">
										<h:outputText value="#{r.totalRooms}" />
									</f:facet>
									<f:facet name="input">
										<p:inputText id="nInput" value="#{r.totalRooms}"
											style="width:96%" />
									</f:facet>
								</p:cellEditor>
							</p:column>

							<p:column headerText="Price">
								<p:cellEditor>
									<f:facet name="output">
										<h:outputText value="#{r.price}" prefix="€" />
									</f:facet>
									<f:facet name="input">
										<p:inputText id="priceInput" value="#{r.price}"
											style="width:96%" prefix="€" />
									</f:facet>
								</p:cellEditor>
							</p:column>

						</p:dataTable>
					</p:column>
					<p:column>
						<p:message for="rooms" />
					</p:column>
				</p:row>
				<f:facet name="footer">
					<p:row>
						<p:column colspan="3">
							<p:commandButton value="Update" action="#{modifyProductBean.saveHotel()}"
								update=":hotelForm" />
							<p:commandButton value="Delete" action="#{modifyProductBean.deleteHotel()}"
								update=":hotelForm" />
						</p:column>
					</p:row>
				</f:facet>
			</p:panelGrid>
		</h:form>

		<h:form id="excursionForm" rendered="#{modifyProductBean.isExcursion}">
			<p:panelGrid columns="3" id="excursionPanel" style="height: 100%">
				<f:facet name="header">
					<p:outputLabel value="Add excursion" />
				</f:facet>
				<p:outputLabel value="name: " for="nameEChoice" />
				<p:inputText id="nameEChoice"
					value="#{modifyProductBean.excursion.name}" size="25" />
				<p:message for="nameEChoice" />

				<p:outputLabel value="location: " for="locationEChoice" />
				<p:selectOneMenu id="locationEChoice"
					value="#{modifyProductBean.excursion.location}"
					converter="locationConverter">
					<f:selectItem itemLabel="Select One" itemValue="" />
					<f:selectItems value="#{applicationDataBean.locations}" var="l"
						itemLabel="#{l.name}" itemValue="#{l}" />
				</p:selectOneMenu>
				<p:message for="locationEChoice" />

				<p:outputLabel value="duration (days): " for="durationSelection" />
				<p:spinner id="durationSelection"
					value="#{modifyProductBean.excursion.duration}" min="1" max="100" />
				<p:message for="durationSelection" />

				<p:outputLabel value="price: " for="priceESelection" />
				<p:inputText id="priceESelection"
					value="#{modifyProductBean.excursion.price}">
					<f:validator validatorId="numberValidator" />
				</p:inputText>
				<p:message for="priceESelection" />

				<p:outputLabel value="Starting at: " for="weekDay" />
				<p:selectOneMenu id="weekDay"
					value="#{modifyProductBean.excursion.weekDay}">
					<f:selectItems value="#{applicationDataBean.weekDays}" />
				</p:selectOneMenu>
				<p:message for="weekDay" />

				<f:facet name="footer">
					<p:commandButton value="Update"
						action="#{modifyProductBean.saveExcursion()}"
						update=":excursionForm" />
					<p:commandButton value="Delete" action="#{modifyProductBean.deleteExcursion()}"
								update=":excursionForm" />
				</f:facet>
			</p:panelGrid>
		</h:form>
	</p:panelGrid>

</body> 
</html>
